Skip to content

Preserve Python exceptions, fix PyO3 panics, and keep Arrow extensions - #12327

Open
lwwmanning wants to merge 3 commits into
developfrom
wm/fix-python-exceptions-and-ext-export
Open

lwwmanning wants to merge 3 commits into
developfrom
wm/fix-python-exceptions-and-ext-export

Conversation

@lwwmanning

@lwwmanning lwwmanning commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Python callbacks in readable.rs and PythonArrayIterator previously formatted PyErr into vortex_err!, turning OSError, EOFError, BufferError, ValueError, and KeyboardInterrupt into RuntimeError; they now attach the original PyErr via VortexError::external and PyVortexError walks the error source chain to re-raise it (with ArrayIterator.__next__ wrapping StopIteration in RuntimeError per PEP 479 so read failures cannot silently truncate iteration). Also eliminates Rust panics across PyO3 when converting nullable StructArrays with top-level nulls to RecordBatch (shared via vortex-layout::scan::arrow::to_record_batch and vortex_err_to_arrow, now pub in vortex-layout, across file, dataset, and iterator exports) or setting StructScalar dict entries, and preserves Arrow extension field metadata during chunked and single extension array exports (related to #11114).

Behavior change: callers that previously caught RuntimeError from failing Python reader or iterator callbacks now receive the original OSError, EOFError, BufferError, ValueError, or KeyboardInterrupt.

Assisted by Antigravity.

… metadata

Signed-off-by: Will Manning <will@willmanning.io>
@lwwmanning lwwmanning added the changelog/fix A bug fix label Nov 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T18:50:21.760006Z 9c8fbc8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@vortex-roborev-bot

vortex-roborev-bot Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

roborev: Combined Review (9ecd0c0)

Verdict: No issues found.


Reviewers: claude-code | Synthesis: claude-code, 0s | Total: 1m7s, cost partial ~$0.49

@vortex-roborev-bot vortex-roborev-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line comments for the roborev review of 9c8fbc8. The roborev PR comment has the full review.

Comment thread vortex-python/test/test_fork.py Resolved
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

Keeping the original Python exception is a good fix.

  • vortex-layout/src/scan/arrow.rs line 73: VortexFile.to_arrow() (vortex-python/src/file.rs line 598) still goes through this to_record_batch, which calls the panicking RecordBatch::from. A file whose root is a nullable struct with null rows still panics there, as Codex said. The dataset and iterator paths in this PR have the same shape: a non-nullable struct target, then a struct to record batch conversion. Please put the checked conversion in the shared to_record_batch in vortex-layout, and call it from dataset.rs line 547 and iter/mod.rs line 216. Then you can remove struct_array_to_record_batch from vortex-python/src/arrow.rs line 317, and all three paths are covered.
  • vortex-python/test/test_fork.py lines 38 to 43: this change is outside the scope of the title and description. It also removes the only tests that unpickle a VortexFile (pickled_file_reads_in_child) and a vortex.Array (write_after_parent_write) in a fresh interpreter under spawn and forkserver. The new docstring on lines 6 to 9 says VortexFile pickling is still covered, but it is not. Please revert this file. If you keep it, add both scenarios under spawn.
  • Note: callers that caught RuntimeError now get OSError, EOFError, BufferError or ValueError. The test_file.py change shows this. Please name this as a user-visible behavior change in the description.

…_fork.py

Move the checked StructArray-to-RecordBatch conversion into vortex-layout::scan::arrow::to_record_batch (preserving InvalidArgumentError via vortex_err_to_arrow) so VortexFile.to_arrow(), VortexDataset.to_record_batch_reader(), and ArrayIterator.to_arrow() all reject top-level struct nulls cleanly, and revert the out-of-scope test_fork.py change.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Addressed all three points in c7c8de7fe:

  • Moved the checked StructArray-to-RecordBatch conversion into vortex-layout::scan::arrow::to_record_batch (with vortex_err_to_arrow preserving InvalidArgumentError), wired dataset.rs and iter/mod.rs through it, removed struct_array_to_record_batch from vortex-python/src/arrow.rs, and added tests for VortexFile.to_arrow() and VortexDataset.to_record_batch_reader().
  • Reverted vortex-python/test/test_fork.py.
  • Updated the PR description to call out the exception-type behavior change.

devin-ai-integration[bot]

This comment was marked as resolved.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

Commit c7c8de7 resolves the earlier review. The checked conversion now sits in the shared to_record_batch in vortex-layout, so the file, dataset and iterator readers return an error and do not panic. The new test_file.py case covers the file and dataset paths, and test_fork.py now matches develop again.

One note for the description: to_record_batch (which was pub(crate)) and vortex_err_to_arrow are now public API in vortex-layout.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread vortex-python/src/iter/mod.rs Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant